[YouTube] Extract client version from service worker data#1520
[YouTube] Extract client version from service worker data#1520FineFindus wants to merge 1 commit into
Conversation
|
absurdlylongusername
left a comment
There was a problem hiding this comment.
Thank you for this PR @FineFindus
After reading #872 I don't think I see how this resolves it.
That issue mentions https://www.youtube.com/sw.js no longer containing something, but from what I see it still has the client version, so I presume it no longer has the API key and we used to get it from there.
The issue says it wants to find way to get both client version and API key, but your PR only gets client version from what I can see.
So given that I don't think this closes #872. Please correct me if I'm wrong.
Additionally, what is the benefit of getting client version from sw.js_data instead of sw.js?
Also:
- I believe this will need to update all of related YT mocks as it's calling a new endpoint that returns a new response
- Please add tests that prove that this works
It seems when logged in calling the URL returns different data. When logged out I only get self.addEventListener('install', event => {
event.waitUntil(self.skipWaiting());
});
self.addEventListener('activate', event => {
event.waitUntil(
self.clients.claim().then(() => self.registration.unregister()));
});
API keys are not used anymore, see #1168.
Not quite sure what's the best way to test this, since the method is private and the public function that uses it still works, since it falls back to extracting the version from the HTML page? |
It does. The InnerTube API doesn't require an API key for a few years now. |
|
@FineFindus Ah okay my bad, I was logged in 🤦♂️. Thank you for this information
Okay I've looked at the surrounding code, I think not worth refactoring to be able to test this explicitly neither is it quick or straightforward to do so. What we should have is a test specifically for getting client version that tests the contract of getting the client version, and tests each branch of the method, but that's prob too much for this PR. Still need to update the mocks though. |



Fixes extracting the web client version, by extracting the version from the service worker data (
https://www.youtube.com/sw.js_data). This avoids the additional request, which is necessary after failing to extract the version, when falling back to extracting version from the search page.Closes: #872